package com.ewing.extranal.im.dto;

import java.util.concurrent.atomic.AtomicLong;

import com.ewing.extranal.im.contant.ImMessageType;

/**
 * 聊天历史记录
 * 
 * @author tansonlam
 * @createDate 2016年4月21日
 * 
 */
public class MessageItem {
    private final static String messageClassPrefix = "imc_li_";
    private static AtomicLong increaseNumber = new AtomicLong(1);

    public MessageItem() {
        this.messageId = String.valueOf(increaseNumber.incrementAndGet());
    }

    /**
     * 消息ID
     */
    private String messageId;
    /**
     * 接受者用户ID
     */
    private Long revImUserId;
    /**
     * 发送者用户ID
     */
    private Long sendImUserId;
    /**
     * 消息的接收方
     */
    private Long relImUserId;
    /**
     * 头像ICON
     */
    private String iconUrl;
    /**
     * 聊天内容
     */
    private String content;
    /**
     * 聊天时间
     */
    private String time;
    /**
     * 消息类型 1：发送 2：接收
     */
    private Integer messageType;
    /**
     * 消息类型样式
     */
    private String messageTypeClass;
    /**
     * 是否已读
     */
    private String readStatus;

    public Long getRelImUserId() {
        return relImUserId;
    }

    public void setRelImUserId(Long relImUserId) {
        this.relImUserId = relImUserId;
    }

    public String getReadStatus() {
        return readStatus;
    }

    public void setReadStatus(String readStatus) {
        this.readStatus = readStatus;
    }

    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }

    public String getIconUrl() {
        return iconUrl;
    }

    public void setIconUrl(String iconUrl) {
        this.iconUrl = iconUrl;
    }

    public Integer getMessageType() {
        return messageType;
    }

    public void setMessageTypeByRelImUserId(Long relImUserId) {
        if (revImUserId.equals(relImUserId)) {
            setMessageType(ImMessageType.SEND.getValue());
        } else {
            setMessageType(ImMessageType.REC.getValue());
        }
    }

    public void setMessageType(Integer messageType) {
        this.messageType = messageType;
        if (ImMessageType.SEND.getValue().equals(messageType)) {
            messageTypeClass = messageClassPrefix + "send";
        } else if (ImMessageType.REC.getValue().equals(messageType)) {
            messageTypeClass = messageClassPrefix + "receive";
        }
    }

    public String getMessageTypeClass() {
        return messageTypeClass;
    }

    public void setMessageTypeClass(String messageTypeClass) {
        this.messageTypeClass = messageTypeClass;
    }

    public Long getRevImUserId() {
        return revImUserId;
    }

    public void setRevImUserId(Long revImUserId) {
        this.revImUserId = revImUserId;
    }

    public Long getSendImUserId() {
        return sendImUserId;
    }

    public void setSendImUserId(Long sendImUserId) {
        this.sendImUserId = sendImUserId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

}
